/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package RMI;

import java.sql.ResultSet;

/**
 *
 * @author TNT
 */
public class Admin {
    Connect connect ;
    ResultSet rs;
    String chuoi[];
    public Admin(String[] chuoi){
        this.chuoi = chuoi;
        connect = new Connect(chuoi);
    }
    public String checkAdmin(String id, String password){
        String Admin="0";
        String sql = "select * from admin where User ='"+id+"'";
        try{
            rs = connect.st.executeQuery(sql);
            if(rs.next()){
                String pass = rs.getString("Password");
                String Name = rs.getString("Name");
                String Phone = rs.getString("Phone");
                String Email = rs.getString("Email");
                if(pass.equals(password)){
                   Admin = id+"###"+pass+"###"+Name+"###"+Phone+"###"+Email;
                }
                else Admin = "0";
            }
            else Admin ="-1";
        }
        catch(Exception ex){
            Admin = "-2";
        }
        return Admin;
    }
}
